package com.mku.parkingmanagement_service.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mku.parkingmanagement_service.entity.Fee;
import com.mku.parkingmanagement_service.service.FeeService;
import com.mku.parkingmanagement_service.dto.FeeUserDTO;
import com.mku.parkingmanagement_service.vo.comm.ResultVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @className: FeeController
 * @author: Maoxx
 * @date: 2024/11/8 23:07
 * @Version: 1.0
 * @description:
 */

@RestController
@RequestMapping("/fee")
public class FeeController {

    @Resource
    private FeeService feeService;

    @PutMapping("/userFee")
    public ResultVO<Object> userFee(@RequestBody FeeUserDTO feeUserDTO) {
        return feeService.userFee(feeUserDTO);
    }

    @GetMapping("/list")
    public ResultVO<Object> list(String carType) {
        return ResultVO.success(feeService.list(new QueryWrapper<Fee>().like("car_type",carType)));
    }

    @PutMapping("/update")
    public ResultVO<Object> update(@RequestBody Fee fee) {
        return feeService.updateById(fee) ? ResultVO.success() : ResultVO.fail();
    }
}
